package com.nbsaas.boot.example.rest.resource;

import com.nbsaas.boot.example.api.apis.ExampleApi;
import com.nbsaas.boot.example.data.entity.Example;
import com.nbsaas.boot.example.api.domain.request.ExampleRequest;
import com.nbsaas.boot.example.api.domain.response.ExampleResponse;
import com.nbsaas.boot.example.api.domain.simple.ExampleSimple;
import com.nbsaas.boot.example.rest.convert.ExampleSimpleConvert;
import com.nbsaas.boot.example.rest.convert.ExampleEntityConvert;
import com.nbsaas.boot.example.rest.convert.ExampleResponseConvert;
import com.nbsaas.boot.example.data.repository.ExampleRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   客户案例-业务接口实现
*/
@Transactional
@Service
public class ExampleResource extends BaseResource<Example,ExampleResponse, ExampleSimple, ExampleRequest>  implements ExampleApi {

    @Resource
    private ExampleRepository exampleRepository;

    @Override
    public JpaRepositoryImplementation<Example, Serializable> getJpaRepository() {
        return exampleRepository;
    }

    @Override
    public Function<Example, ExampleSimple> getConvertSimple() {
        return new ExampleSimpleConvert();
    }

    @Override
    public Function<ExampleRequest, Example> getConvertForm() {
        return new ExampleEntityConvert();
    }

    @Override
    public Function<Example, ExampleResponse> getConvertResponse() {
        return new ExampleResponseConvert();
    }




}


